home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / circularFilletPreset.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  5.0 KB  |  197 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April 29, 1997
  22. //  Author:        RS 
  23. //
  24. //  Description:
  25. //      The circularFilletPreset() procedure executes one circular fillet (
  26. //        rollingBall fillet really !) operation given two NURBS surfaces,
  27. //      based on the option vars. 
  28. //
  29. //  Input Arguments:
  30. //      None.
  31. //
  32. //  Return Value:
  33. //      None.
  34. //
  35.  
  36.  
  37. proc string pieceTogetherCmd(
  38.     int $doHistory,
  39.     int $asPolygons,
  40.     float $pr,
  41.     int   $revPrimary,
  42.     int   $revSecondary,
  43.     float $c0tol,
  44.     float $g1tol,
  45.     int $genCos )
  46. //
  47. //    Description :
  48. //        Put together an extrude Cmd.
  49. //
  50. {
  51.     string $cmd = "circularFillet" ;
  52.  
  53.     // history.
  54.     //
  55.     $cmd = $cmd + " -ch " ;
  56.     if( $doHistory == 1 ) $cmd = $cmd + "true" ;    
  57.     else $cmd = $cmd + "false" ;
  58.  
  59.     //$cmd = $cmd + " -po " ;
  60.     //if( $asPolygons == 1 ) $cmd = $cmd + "true" ;
  61.     //else $cmd = $cmd + "false" ;
  62.     
  63.     // primary radius.
  64.     //
  65.     $cmd = $cmd + " -pr " ;
  66.  
  67.     float $prad = $pr ;
  68.     if( $revPrimary == 1 ) $prad = $prad * -1 ;
  69.     $cmd = $cmd +  $prad ;
  70.  
  71.     // secondary radius.
  72.     //
  73.     $cmd = $cmd + " -sr " ;
  74.     float $srad = $pr ;
  75.     if( $revSecondary == 1 ) $srad = $srad * -1 ;
  76.     $cmd = $cmd +  $srad ;
  77.  
  78.     // position continuity tol.
  79.     //
  80.     $cmd = $cmd + " -pt " ;
  81.     $cmd = $cmd + $c0tol ;
  82.  
  83.     // g1 continuity tolerance.
  84.     //
  85.     $cmd = $cmd + " -tt " ;
  86.     $cmd = $cmd + $g1tol ;
  87.  
  88.     // generate cos.
  89.     //    
  90.     $cmd = $cmd + " -cos " ;
  91.     if( $genCos == 1 ) {
  92.         $cmd = $cmd + "true" ;
  93.     } else {
  94.         $cmd = $cmd + "false" ;
  95.     }
  96.     
  97.  
  98.     return $cmd ;
  99. }
  100.  
  101. global proc circularFilletPreset(
  102.     int $doHistory,
  103.     int $asPolygons,
  104.     float $pr,
  105.     int   $revPrimary,
  106.     int   $revSecondary,
  107.     float $c0tol,
  108.     float $g1tol,
  109.     int $genCos ) 
  110. //
  111. //    Description :
  112. //        Proc to do one circular fillet operation.
  113. //
  114. {
  115.     //---------------------------------------------
  116.     // Get the list of nurbs surfaces in select list. 
  117.     //---------------------------------------------
  118.     //
  119.     global int $gSelectNurbsSurfacesBit;
  120.     global int $gSelectIsoparmsBit;
  121.     global int $gSelectSurfaceParmPointsBit;
  122.     global int $gSelectCurvesOnSurfacesBit;
  123.     string $inpList[] = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit `;
  124.  
  125.     string $filletPair[2];
  126.  
  127.     //--------------------------------------------
  128.     // Valid # of items.
  129.     //--------------------------------------------
  130.     //
  131.     int $count = size($inpList) ;
  132.     if( $count >= 2 ) {
  133.         if( $count > 2 ) {
  134.                warning ("Only two surfaces should be selected to do circular " +
  135.                      "fillet. The last 2 selected surfaces will be used.");
  136.         }
  137.         $filletPair[0] = $inpList[$count-2];
  138.         $filletPair[1] = $inpList[$count-1];
  139.     }
  140.     else {
  141.         $revPrimary = 0;
  142.         $revSecondary = 0;
  143.         if( $pr < 0 ) $pr = -1 * $pr;
  144.  
  145.         $inpList = `filterExpand -ex true -sm $gSelectIsoparmsBit -sm $gSelectSurfaceParmPointsBit`;
  146.         $count = size($inpList) ;
  147.  
  148.         // These would be isoparms or surface points:
  149.         if( $count >= 2 ) {
  150.             if( $count > 2 ) {
  151.                 warning ("Only two surface isoparms or points should be " +
  152.                          "selected to do circular fillet. The last 2 " +
  153.                          "selected will be used.");
  154.             }
  155.             $filletPair[0] = $inpList[$count-2];
  156.             $filletPair[1] = $inpList[$count-1];
  157.         }
  158.     }
  159.  
  160.     if( $count < 2 ) {
  161.         error ("Select two NURBS surfaces, two isoparms or two surface " +
  162.                  "points to do circular fillet"); 
  163.     }
  164.  
  165.     if( $count >= 2 ) {
  166.         //---------------------------------------
  167.         // put together an rolling ball fillet cmd.
  168.         //---------------------------------------
  169.         //
  170.         string $cmd = pieceTogetherCmd(    $doHistory, $asPolygons, $pr, $revPrimary,
  171.                                         $revSecondary, $c0tol, $g1tol, $genCos);
  172.  
  173.         //----------------------------------------
  174.         // place holders for 2 selection items.
  175.         //----------------------------------------
  176.         //
  177.         int $nitems = 2 ;
  178.         $cmd = appendToCmdPlaceHoldersForSelectionItems($cmd,$nitems) ;
  179.  
  180.         string $results[] = executeCmdOnItems($cmd,$filletPair);    
  181.  
  182.         // select all results.
  183.         //
  184.         $count = size($results) ;
  185.            $selectString = "select -r ";
  186.         int $i ;
  187.         for( $i = 0 ; $i < $count ; $i++ ) {
  188.             $selectString +=  $results[$i] ;
  189.             $selectString += " ";    
  190.         }
  191.         $selectString += ";";
  192.         select -cl ;
  193.         eval($selectString) ;
  194.     }
  195. }
  196.  
  197.